﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Albums;
using VK.Comm.TransactSql;
using System.Data;

namespace VK.Casemeet.Web.Front
{
    public partial class AlbumList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TopShop1.AreaUrl = (this.Master as Site).GetAreaUrl();
            TopShop1.ProvinceID = (this.Master as Site).provinceID;
            TopShop1.CityID = (this.Master as Site).cityID;

            if (!IsPostBack)
            {
                aspNetPager.RecordCount = AlbumBLL.GetShopAlbumCount(GetCondition());
            }
        }

        protected void LoadData()
        {
            rptAlbum.DataSource = AlbumBLL.GetShopAlbumList(aspNetPager.StartRecordIndex, aspNetPager.EndRecordIndex, GetCondition(), null, SortMode.Desc);
            rptAlbum.DataBind();
        }

        protected IList<Condition> GetCondition()
        {
            IList<Condition> conditionlst = new List<Condition>();
            conditionlst.Add(new Condition { TableName = "Shop", FieldName = "ProvinceID", ConditionType = ConditionType.NumeralEqual, ConditionValue = (this.Master as Site).GetCurrentAreaID(), DbType = DbType.Int32 });
            conditionlst.Add(new Condition { TableName = "Album", FieldName = "ObjectType", ConditionType = ConditionType.NumeralEqual, ConditionValue = 1, DbType = DbType.Int32 });
            return conditionlst;
        }

        protected void aspNetPager_PageChanged(object sender, EventArgs e)
        {
            LoadData();
        }
    }
}